// packageAPI/pages/device/beacon/beacon.js
Page({

  data: {
    schema:[],
    title:'蓝牙-信标',
    result:'',
    formData:{}
  },

  onLoad(options) {
    this.setData({
      title: options.title,
      zh:options.zh,
      remark:options.remark,
      docUrl:options.docUrl
    })
  },
  startBeaconDiscovery(){
    wx.startBeaconDiscovery({
      uuids: ['12345678-9012-3456-7890-123456789012'],
      success:(e)=>{
        wx.onBeaconUpdate(res => {
          this.setData({
            result:res
          })
       })
       wx.onBeaconServiceChange(res => {
          this.setData({
            result:res
          })
        })  
      },
      fail:(e)=>{
        this.setData({
          result:e
        })
      }
    })
  },
  getBeacons(){
    wx.getBeacons({
      complete:(e)=>{
        this.setData({
          result:e
        })
      }
    })
  },
  offBeaconUpdate() {
    wx.offBeaconUpdate()
  },
  offBeaconServiceChange() {
    wx.offBeaconServiceChange()
  },
  stopBeaconDiscovery(){
    wx.stopBeaconDiscovery({
      complete:(e)=>{
        this.setData({
          result:e
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

})